stage.set_background_color("black")
amount = 10
speed = 5
color_list = ["purple", "yellow", "red"]
stage.disable_all_walls()
def click():
x = stage.click_x()
y = stage.click_y()
particle_list = []
for color in color_list:
for counter in range(amount):
sprite = codesters.Circle(x, y, 10, color)
particle_list.append(sprite)
# add other actions...
stage.event_click(click)
t = codesters.Teacher()
find_angle = t.find_text('angle')
find_count = t.find_text('count')
find_vars = t.find_text('my_var')
try:
tval1a = t.get_indent_at_line(find_angle[0][0])
angle_text = find_angle[0][1].split('=')
tval1b = angle_text[1].replace(" ", "")
except:
tval1a = -1
tval1b = "DNE"
try:
tval2a = t.get_indent_at_line(find_count[1][0])
count_text = find_count[1][1].split('=')
tval2b = count_text[1].replace(" ", "")
except:
tval2a = -1
tval2b = "DNE"
try:
tval3 = len(find_vars)
except:
tval3 = -1
t1 = TestObjective()
t1.add_success(tval1a == 4 and tval1b == 0, "Great Job!")
t1.add_failure(tval1a == -1, "Did you add an integer variable named angle?")
t1.add_failure(tval1b != '0'', "Oops! Did you change the value of angle?")
t1.add_failure(tval1a != -1 and tval1a != 4, "Oops! Make sure angle is indented ONCE!")
# t2 = TestObjective()
# t2.add_success(tval2a == 4 and tval2b == 0, "Great Job!")
# t2.add_failure(tval2a == -1, "Did you add an integer variable named count?")
# t2.add_failure(tval2b != '0'', "Oops! Did you change the value of count?")
# t2.add_failure(tval2a != -1 and tval2a != 4, "Oops! Make sure count is indented ONCE!")
################################################
# Pass test code
# - set pass_required to True if pass is required to prevent bad input error
# - include tpass before t1 in the test list
pass_required = False
passes = t.find_text("pass")
num_pass_only = 0
for p in passes:
if p[1].lower().replace(' ','') == "pass":
num_pass_only += 1
tpass = TestObjective()
if not pass_required:
tpass.add_success(num_pass_only == 0, "Great job!")
tpass.add_creative(num_pass_only > 0, "Great job! Feel free to delete pass statements now.")
################################################
tester = TestManager()
tester.add_test_list([tpass, t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)